/**
 *
 */
package com.lanyou.esb.servicemix.monitor.rest;

import java.io.IOException;
import java.net.CookieManager;
import java.net.URI;
import java.util.List;
import java.util.Map;

/**
 * @author gonglei
 */
public class UserCookieManager extends CookieManager {

    private String sessionId;

    @Override
    public void put(URI uri, Map<String, List<String>> responseHeaders) throws IOException {
        super.put(uri, responseHeaders);
        super.put(uri, responseHeaders);
        if (responseHeaders != null && responseHeaders.get("Set-Cookie") != null)
            for (String string : responseHeaders.get("Set-Cookie")) {
                if (string.contains("JSESSIONID")) {
                    sessionId = string;

                }
            }
    }

    public String getSessionId() {
        return sessionId;
    }

}
